<template>
  <div class="parent">
    <h2>使用 emits 传递父子组件数据</h2>
    <button @click="counter++">add</button>
    <span v-if="toy">从子组件获取 {{ toy }}</span>
    <sub-comp :pin-money="counter" @change-toy="saveToy" />
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import SubComp from "./SubComp.vue";

const counter = ref(1);
const toy = ref("");
function saveToy(v: string) {
  toy.value = v;
}
</script>

<style scoped>
@import "../common.css";
</style>
